export default {
  data() {
    return {
      index: -1,
      picker: ['0%', '1%', '2%', '3%', '4%', '5%', '6%', '9%', '10%', '11%', '13%'],
      oldTax: '',
      newTax: 0,
      taxCount: 0,
      taxPercent: ''
    }
  },
  watch: {
    'oldTax'(e) {
      if(this.taxPercent != '' || this.taxPercent != null || this.taxPercent != undefined) {
        const oldTax = Number(e)
        const newTax = oldTax/(1+this.taxPercent.replace('%', '')/100)
        this.newTax = newTax.toFixed(2)
        this.taxCount = (oldTax - Number(newTax)).toFixed(2)
      }
    }
  },
  methods: {
    PickerChange(e) {
      this.index = e.detail.value
      this.taxPercent = this.picker[e.detail.value]
      const oldTax = Number(this.oldTax)
      const newTax = oldTax/(1+this.picker[e.detail.value].replace('%', '')/100)
      this.newTax = newTax.toFixed(2)
      this.taxCount = (oldTax - Number(newTax)).toFixed(2)
    },
  }
}